﻿@model Matrix.MaKaYunShang.Model.LanJianAwards
@{
    ViewBag.Title = "添加蓝剑奖品";
    ViewBag.PathToBtn = "/LanJianAwards/List";
    ViewBag.TextBtn = "返回至列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                蓝剑奖品信息
            </div>
            <div class="panel-body">
                <div class="row">
                    @using (Html.BeginForm("Create", "LanJianAwards", FormMethod.Post, new { id = "frmCreate", enctype = "multipart/form-data" }))
                    {
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)
                        
                        <div class="col-lg-12">
                            <fieldset>
                                <div class="form-group col-md-12">
                                    <input id="fileImage" class="form-control" type="file" name="fileImage" style="display: none;" />
                                    <input id="btnSelect" type=button class="btn btn-info" value="上传列表图" onclick=" fileImage.click() " />
                                    <img id="imgThumb" alt="缩略图" style="max-height: 80px" src="/Content/admin/image/uploadimg.png" imgpath="/Content/admin/image/uploadimg.png" />
                                    <span>（建议尺寸：宽180*高180，200KB以内）</span>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>奖品名称</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.AwardName, new { @class = "form-control", placeholder = "奖品名称", maxlength = 30 })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>跳转链接</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.JumpUrl, new { @class = "form-control", placeholder = "跳转链接", maxlength = 1000 })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>奖品总数</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.TotalQuantity, new { @class = "form-control", placeholder = "奖品总数", maxlength = 8 })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>是否参与抽奖</label>
                                    <br />
                                    <label>
                                        @Html.RadioButtonFor(model => model.IsOpen, "true") 是
                                    </label>&nbsp;&nbsp;
                                    <label>
                                        @Html.RadioButtonFor(model => model.IsOpen, "false") 否
                                    </label>
                                </div>
                                <div class="col-md-12">
                                    <button id="btnSave" type="submit" class="btn btn-primary">保存</button>
                                    <button id="btnReset" type="reset" class="btn btn-outline btn-primary">清空设置</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
@section javascript{
    <script src="/Content/admin/dist/js/imageUploader.js"> </script>
    <script type="text/javascript">
        // Image Upload
        imageUploader.uploadSingle(fileImage, btnSelect, imgThumb, '');

        $(function () {
            $("#frmCreate").validate({
                rules: {
                    AwardName: { required: true },
                    JumpUrl: { required: true },
                    TotalQuantity: { required: true, digits: true, min: 0 }
                },
                messages: {
                    AwardName: { required: "请填写j奖品名称" },
                    JumpUrl: { required: "请填写跳转链接" },
                    TotalQuantity: { required: "请填写奖品总数" }
                },
                submitHandler: function (form) {
                    if ($("#fileImage").val() == "") {
                        return alertify.alert('请上传奖品图');
                    }
                    form.submit();
                }
            });
        });
    </script>
}